//
//  RealTimeLogWindow.h
//  DualMediation
//
//  Created by YeJary on 2025/6/23.
//

#import <UIKit/UIKit.h>
#import "IMLogUtils.h"

NS_ASSUME_NONNULL_BEGIN

@interface RealTimeLogWindow : UIView <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>

// 显示控制
@property (nonatomic, assign, readonly) BOOL isVisible;
@property (nonatomic, copy, nullable) void(^onClose)(void);

- (instancetype)initWithFrame:(CGRect)frame;
- (void)show;  // 显示日志窗口
- (void)hide;  // 隐藏日志窗口
- (void)addLog:(NSString *)message;  // 添加日志消息
- (void)showWithAnimation:(BOOL)animated;
- (void)hideWithAnimation:(BOOL)animated;
- (void)addLogMessage:(NSString *)message;
- (void)clearLogs;

#pragma mark - IMLogUtils Integration

/// 启用IMLogUtils实时监听
/// @param enable 是否启用
- (void)enableIMLogMonitoring:(BOOL)enable;

/// 设置日志级别过滤
/// @param minLevel 最小显示级别
- (void)setMinimumLogLevel:(IMLogLevel)minLevel;

/// 设置标签过滤（nil表示显示所有标签）
/// @param tags 要显示的标签数组
- (void)setVisibleLogTags:(nullable NSArray<NSNumber *> *)tags;

/// 加载历史日志文件
/// @param filePath 日志文件路径，nil表示加载当前日志文件
- (void)loadLogFile:(nullable NSString *)filePath;

/// 设置日志格式化选项
/// @param showTimestamp 是否显示时间戳
/// @param showLevel 是否显示日志级别
/// @param showTag 是否显示标签
/// @param showThread 是否显示线程信息
- (void)setLogFormat:(BOOL)showTimestamp
           showLevel:(BOOL)showLevel
             showTag:(BOOL)showTag
          showThread:(BOOL)showThread;

/// 搜索日志内容
/// @param keyword 搜索关键词
/// @param caseSensitive 是否大小写敏感
- (void)searchLogs:(NSString *)keyword caseSensitive:(BOOL)caseSensitive;

/// 导出日志到文件
/// @param includeSystemLogs 是否包含系统日志
/// @param completion 完成回调
- (void)exportLogsWithSystemLogs:(BOOL)includeSystemLogs 
                      completion:(nullable void(^)(NSString * _Nullable filePath, NSError * _Nullable error))completion;

/// 获取IMLogUtils统计信息
- (NSDictionary *)getLogStatistics;

@end

NS_ASSUME_NONNULL_END
